﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace if_else
{
    class Program
    {

        //public Program()
        //{
        //    Condition("1");
        //}

        static Dictionary<string, Action> selector = new Dictionary<string, Action>();
        /// <summary>
        /// 重构if else
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Stu stu = new Stu();

            Console.Write("ifelse 重构");
            Condition("1", hao);
            Condition("2", buhao);
            Console.Read();
        }

        public static void Condition(string obj, Action action)
        {
            selector.Add(obj, action);

            selector[obj]();
        }
        public static void buhao()
        {
            Console.Write("第一种");
        }

        public static void hao()
        {
            Console.Write("第二种");
        }

        public class Stu
        {
        }
    }
}
